﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Demo.Migrations;

/// <inheritdoc />
public partial class Update_Abp_723 : Migration
{
    /// <inheritdoc />
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.AddColumn<int>(
            name: "EntityVersion",
            table: "AbpUsers",
            type: "int",
            nullable: false,
            defaultValue: 0);

        migrationBuilder.AddColumn<DateTimeOffset>(
            name: "LastPasswordChangeTime",
            table: "AbpUsers",
            type: "datetimeoffset",
            nullable: true);

        migrationBuilder.AddColumn<bool>(
            name: "ShouldChangePasswordOnNextLogin",
            table: "AbpUsers",
            type: "bit",
            nullable: false,
            defaultValue: false);

        migrationBuilder.AddColumn<int>(
            name: "EntityVersion",
            table: "AbpTenants",
            type: "int",
            nullable: false,
            defaultValue: 0);

        migrationBuilder.AddColumn<int>(
            name: "EntityVersion",
            table: "AbpRoles",
            type: "int",
            nullable: false,
            defaultValue: 0);

        migrationBuilder.AddColumn<int>(
            name: "EntityVersion",
            table: "AbpOrganizationUnits",
            type: "int",
            nullable: false,
            defaultValue: 0);

        migrationBuilder.CreateTable(
            name: "AbpUserDelegations",
            columns: table => new
            {
                Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                SourceUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                TargetUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                StartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                EndTime = table.Column<DateTime>(type: "datetime2", nullable: false)
            },
            constraints: table => table.PrimaryKey("PK_AbpUserDelegations", x => x.Id));
    }

    /// <inheritdoc />
    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropTable(
            name: "AbpUserDelegations");

        migrationBuilder.DropColumn(
            name: "EntityVersion",
            table: "AbpUsers");

        migrationBuilder.DropColumn(
            name: "LastPasswordChangeTime",
            table: "AbpUsers");

        migrationBuilder.DropColumn(
            name: "ShouldChangePasswordOnNextLogin",
            table: "AbpUsers");

        migrationBuilder.DropColumn(
            name: "EntityVersion",
            table: "AbpTenants");

        migrationBuilder.DropColumn(
            name: "EntityVersion",
            table: "AbpRoles");

        migrationBuilder.DropColumn(
            name: "EntityVersion",
            table: "AbpOrganizationUnits");
    }
}
